import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.io.FileInputStream;
import javax.swing.JFrame;

@SuppressWarnings("serial")
public class Test extends JFrame {
	int[][] r, g, b;

	public Test(String filename) throws Exception {
		super("Test IMGtoRGB24");
		r = new int[240][320];
		g = new int[240][320];
		b = new int[240][320];
		FileInputStream input = new FileInputStream(filename);
		int x, y;
		for (y = 0; y < 320; y++)
			for (x = 0; x < 240; x++) {
				r[x][y] = input.read();
				g[x][y] = input.read();
				b[x][y] = input.read();
			}
		input.close();
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setMinimumSize(new Dimension(240, 320));
		this.setVisible(true);
	}

	@Override
	public void paint(Graphics g1) {
		Graphics2D g2 = (Graphics2D) g1;
		int x, y;
		for (y = 0; y < 320; y++)
			for (x = 0; x < 240; x++) {
				g2.setColor(new Color(r[x][y], g[x][y], b[x][y]));
				g2.fillRect(x, y, 1, 1);
			}
	}

	public static void main(String[] args) throws Exception {
		new Test(args[0]);
	}
}
